<?php 
	include_once '../../../include/inc_session.php';

	if(isset($_GET['Identifiant_personne']) && !empty($_GET['Identifiant_personne']))
	{ // Vérifier si Identifiant_personne est passé en paramètre
		$idPersonne = $_GET['Identifiant_personne'];
	}
	$idRole = isset($_POST['idrole'])? $_POST['idrole']: $_GET['idrole'];
	$idContrat = isset($_POST['idcontrat'])? $_POST['idcontrat']: $_GET['idcontrat'];
	
	$oRefExt = new dataObject_refExterne();
	
	$TYPE    =  (isset($_POST['Type_refexterne']))  ?  $_POST['Type_refexterne']  : '';
	$VALEUR    =  (isset($_POST['ORE_Valeur_refexterne'])) ?  $_POST['ORE_Valeur_refexterne'] : '';

	if ($gbFormValid) 
	{
		$oRefExt->_TYPE_REFEXT 			= $TYPE;
		$oRefExt->_VALEUR_REFEXT 			= $VALEUR;
		$oRefExt->_IDENTIFIANT_PERSONNE 	= $_POST['Identifiant_personne'];
		$oRefExt->_IDENTIFIANT_ROLE 		= $idRole;
		$oRefExt->_IDENTIFIANT_CONTRAT 	= $idContrat;
		
		$id = $oRefExt->refExterne_insert();
		
		if(!$id) $oForm->ajouterErreur(chgmt_couv_crea_refext_pbm);
		else $oForm->ajouterErreur(refexterne_creation);
		//header("location:index.php?Identifiant_personne=".$idPersonne);
	}

	$nom_module_saisie="Détail référence externe";

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=8" />
			<title>Références externes</title>
			<link rel="stylesheet" type="text/css" href="../../../css/main.css" />
            <link rel="stylesheet" type="text/css" href="list.css" />
			<!--[if IE 7]>
            	<link rel="stylesheet" type="text/css" href="../../../css/ie7.css" />
            	<link rel="stylesheet" type="text/css" href="form_ie7.css" />
            <![endif]-->
	</head>

<body>
<div id="sf_menu1">
	<h3><?php echo $oBloc->_MENU_NOM ?></h3>
	<div id="information_erreur" class="false">
        <ul id="message">
        	<li><?php $aMsg =$oForm->getValidMessage(); echo (!empty($aMsg))? $aMsg[0]['message'] : ''; ?></li>
        </ul>
    </div>

</div>
<div class="cleared"></div>

<div class="corps1">
<!--/***************************************/-->

	<div class="cleared"></div>
	<div id="br"></div>


<form action="<?php echo $sEditFormAction; ?>" method="post" name="form1" id="form1">
	<div class="imgleft"></div>
	<div class="imgmiddle">
    <div class="btn">
    	<span class="btnleft"></span>
        <span class="btnmiddle">
        	<h5><?php echo $oFonction->_MENU_AFFICHE; ?></h5>
        </span><span class="btnright"></span>
    </div>
  	<div class="btn1">
    	<span class="btnleft"></span>
        <span class="btnmiddle">
        	<h5><?php echo $nom_module_saisie; ?></h5>
        </span>
        <span class="btnright"></span>
    </div>
	<div class="formulaire">
  <table class="tabform">
    <tr>
      <td class="td0">TYPE </td>
      <td><select name="Type_refexterne">
		<?php 
		$aTypeList = dataObject_elementdico::elementdico_getListFromCode(dataObject_dictionnaire::_TYPE_REF_EXTERNE);
		foreach ($aTypeList as $i => $aRow)
		{ ?>
			<option value="<?php echo $aRow['Code_element']; ?>" <?php echo remind_select('Type_refexterne', $aRow['Code_element']) ?> ><?php echo $aRow['Nom_element']; ?></option>
		<?php 
		} 
		 ?>
      </select>
      </td>
    </tr>
	
    <tr>
      <td class="td0">VALEUR</td>
      <td><input type="text" name="ORE_Valeur_refexterne" value="<?php echo remind_text('ORE_Valeur_refexterne'); ?>" size="32" maxlength="30" /></td>
    </tr>
	
  </table>
    </div>
</div>
<div class="imgright"></div>				
<div class="cleared"></div>

<div class="bt1">
	<a href="index.php?Identifiant_personne=<?php echo $idPersonne;?>&idcontrat=<?php echo $idContrat; ?>&idrole=<?php echo $idRole; ?>&msg=1">
    	<span class="btleft"></span>
        <span class="btmiddle">Annuler</span>
        <span class="btright"></span>
    </a>
</div>

<div class="bt">
	<span class="btleft"></span>
    <input type="submit" name="Valider" value="Valider" class="resizeall btmiddle"/>
    <span class="btright"></span>
</div>

<div class="cleared"></div>
  <input type="hidden" name="Identifiant_refext" value="" />
  <input type="hidden" name="MM_insert" value="form1" />
  <input type="hidden" name="Identifiant_personne" value="<?php echo $idPersonne;?>" />
  <input type="hidden" name="idrole" value="<?php echo $idRole;?>" />
  <input type="hidden" name="idcontrat" value="<?php echo $idContrat;?>" />
</form>
 </div>
</body>
</html>
<?php

include_once PATH_INCLUDE.'inc_pied_page.php';
?>